// ActionScript file
package com.spotme
{
	import com.adobe.serialization.json.JSON;
	
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	
	public class JSONLoader
	{
		public var ul:URLLoader;
		public var JSONobject:Object;
		
		public function JSONLoader(urlStr:String, callback:Function)
		{
			ul = new URLLoader(new URLRequest(urlStr));
			ul.addEventListener(Event.COMPLETE, callback);
		}
		public function loaderCompleteHandler(event:Event):void {
			try{
				JSONobject = (JSON.decode(ul.data) as Object);
			}catch(e:Error)
			{
				trace('JSON ERROR:',e.message);	
			} 	
		}
	}
}